package com.hspedu.newData.dmsxl.滑动窗口;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-29 
 * @Version: 1.0
 */

public class LC3392统计符合条件长度为3的子数组数目 {

    public int countSubarrays(int[] nums) {

        int count = 0;

        for (int i = 2; i < nums.length; i++) {
            if ((nums[i-2] + nums[i]) * 2 == nums[i - 1]){
                count ++;
            }
        }
        return count;
    }

    @Test
    public void test() {
        // 测试代码

        int i = countSubarrays(new int[]{-1, -4, -1, 4});
        System.out.println(i);
    }

}
